#define _CRT_SECURE_NO_WARNINGS
//#include  <stdio.h>
//#include  <string.h>
//#define   N   5
//#define   M   8
//void fun(char(*ss)[M])
//{
//    char* ps[N], * tp;    int  i, j, k;
//    for (i = 0; i < N; i++) ps[i] = ss[i];
//    for (i = 0; i < N - 1; i++) {
//        /**********found**********/
//        k = i;
//        for (j = i + 1; j < N; j++)
//            /**********found**********/
//            if (strlen(ps[k]) < strlen(ps[j])) k = j;
//        /**********found**********/
//        tp = ps[i];  ps[i] = ps[k]; ps[k] = tp;
//    }
//    printf("\nThe string after sorting by length:\n\n");
//    for (i = 0; i < N; i++)  puts(ps[i]);
//}
//main()
//{
//    char  ch[N][M] = { "red","green","blue","yellow","black" };
//    int  i;
//    printf("\nThe original string\n\n");
//    for (i = 0; i < N; i++)puts(ch[i]);  printf("\n");
//    fun(ch);
//}


//#include <stdlib.h>
//#include  <conio.h>
//#include  <stdio.h>
//#include  <math.h>
///*************found**************/
//double fun(int n)
//{
//    double sum, s0, s1, s2, s; int k;
//    sum = 1.0;
//    if (n <= 2) sum = 0.0;
//    s0 = 0.0; s1 = 0.0; s2 = 1.0;
//    for (k = 4; k <= n; k++)
//    {
//        s = s0 + s1 + s2;
//        sum += sqrt(s);
//        s0 = s1; s1 = s2; s2 = s;
//    }
//    /*************found**************/
//    return sum;
//}
//void main()
//{
//    int n;
//    system("CLS");
//    printf("Input  N=");
//    scanf("%d", &n);
//    printf("%f\n", fun(n));
//}

#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
double fun(double x, int n)
{
	double ret = 1 + x;
	for (int i = 2; i <= n; i++)
	{
		int fac = 1;
		for (int j = 1; j <= i; j++)
		{
			fac *= j;
		}
		ret += pow(x, i) / fac;
	}
	return ret;
}
void main()
{
	FILE* wf;
	system("CLS");
	printf("%f ", fun(0.3, 10));
	/******************************/
	wf = fopen("out.dat", "w");
	fprintf(wf, "%f", fun(0.3, 10));
	fclose(wf);
	/*****************************/
}
